package jdbc;

import jdbc.util.JdbcUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * 拿到_A% 的 名字
 */
public class jdbcTest02 {
    public static void main(String[] args) {
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        try {
            //获取连接
            conn = JdbcUtil.getconnection();
            //获取预编译的对象
            String sql="select ename from emp  ";
            ps=conn.prepareStatement(sql);
          //  ps.setString(1,"_A%");
            rs=ps.executeQuery();
            boolean flag=false;
            while (rs.next()){
                System.out.println(rs.getString("ename"));
                if ("WARD".equals(rs.getString("ename"))){
                    flag=true;
                }
            }
            System.out.println(flag);



        } catch (SQLException e) {
            e.printStackTrace();
        }finally {

            JdbcUtil.colse(conn,ps,rs);

        }
        }
}
